package com.qf.smartdevice.controller.advices;

import com.qf.smartdevice.dot.Result;
import com.qf.smartdevice.exception.ErrorCode;
import com.qf.smartdevice.exception.MyBaseException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author 王博康
 * @version 1.0
 * @project devicemanagementsystem
 * @description: TODO
 * @date 2022/3/18 23:31 星期五
 */
@RestControllerAdvice
public class MyErrorAdvice {
    @ExceptionHandler(MyBaseException.class)
    public Result processMyBaseException(MyBaseException e ){
        e.printStackTrace();
        return Result.getResult(e.getCode(),e.getMessage() ,null );
    }

    @ExceptionHandler(Exception.class)
    public Result processException(Exception e ){
        e.printStackTrace();
        return Result.getResult(ErrorCode.FAIL,e.getMessage() ,null );
    }
}
